/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Simulation_InterfaceForm.java
 *
 * Created on Nov 30, 2011, 7:42:15 AM
 */
package fmii.ui;

import fmii.control.SimulationControl;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import fmii.control.Control;

/**
 *
 * @author Josh
 */
public class Simulation_Interface extends javax.swing.JPanel {

    /** Creates new form Simulation_InterfaceForm */
    public Simulation_Interface() {
        initComponents();
        
        control = new SimulationControl();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        mass_slider = new javax.swing.JSlider();
        jLabel5 = new javax.swing.JLabel();
        force_slider = new javax.swing.JSlider();
        run_simulation_button = new javax.swing.JButton();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(fmii.MainApp.class).getContext().getResourceMap(Simulation_Interface.class);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        mass_slider.setMajorTickSpacing(5);
        mass_slider.setMaximum(25);
        mass_slider.setMinorTickSpacing(1);
        mass_slider.setPaintLabels(true);
        mass_slider.setPaintTicks(true);
        mass_slider.setSnapToTicks(true);
        mass_slider.setValue(9);
        mass_slider.setName("mass_slider"); // NOI18N
        mass_slider.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                mass_sliderStateChanged(evt);
            }
        });

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        force_slider.setMajorTickSpacing(5);
        force_slider.setMaximum(25);
        force_slider.setMinorTickSpacing(1);
        force_slider.setPaintLabels(true);
        force_slider.setPaintTicks(true);
        force_slider.setSnapToTicks(true);
        force_slider.setValue(4);
        force_slider.setName("force_slider"); // NOI18N
        force_slider.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                force_sliderStateChanged(evt);
            }
        });

        run_simulation_button.setText(resourceMap.getString("run_simulation_button.text")); // NOI18N
        run_simulation_button.setName("run_simulation_button"); // NOI18N
        run_simulation_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                run_simulation_buttonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel4)
                                            .addComponent(jLabel5))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(force_slider, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                                            .addComponent(mass_slider, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE))))))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(run_simulation_button, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(82, 82, 82))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(jLabel4)
                        .addGap(37, 37, 37)
                        .addComponent(jLabel5))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(mass_slider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(force_slider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)))
                .addGap(1, 1, 1)
                .addComponent(run_simulation_button, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(55, 55, 55))
        );
    }// </editor-fold>//GEN-END:initComponents

    
    // RUN SIMULATION (button)
    private void run_simulation_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_run_simulation_buttonActionPerformed
        control.run_simulation();
        // pass parameters to Simulation_Control         // call RUN in Simulation_Control}//GEN-LAST:event_run_simulation_buttonActionPerformed
    
        Control.authorization.exportStudentData();
    }
        private void mass_sliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_mass_sliderStateChanged
        control.set_mass(mass_slider.getValue());  
    }//GEN-LAST:event_mass_sliderStateChanged

    private void force_sliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_force_sliderStateChanged
        control.set_force(force_slider.getValue());
    }//GEN-LAST:event_force_sliderStateChanged

    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JSlider force_slider;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JSlider mass_slider;
    private javax.swing.JButton run_simulation_button;
    // End of variables declaration//GEN-END:variables

    SimulationControl control;
}
